
<?php
/**
* CARE2X Integrated Hospital Information System Deployment 2.2 - 2006-07-10
* GNU General Public License
* Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla
* elpidio@care2x.org, 
*
* See the file "copy_notice.txt" for the licence notice
*/

error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
require('./roots.php');
require($root_path.'include/inc_environment_global.php');

//Importacion y creacion de instancia de la clase queries_interconsulta_usutriaje
$filename = $root_path."db/interconsulta/queries_interconsulta_usutriaje.php";
require_once($filename);
$query_interconsulta_usutriaje = new Queries_interconsulta_usutriaje();

/*el archivo de lenguaje esta en su carpeta correspondiente de idioma y se llama lang_es_interconsulta.php (es en nuestro caso claro...*/
define('LANG_FILE','interconsulta.php');
define('NO_2LEVEL_CHK',1);
require_once($root_path.'include/inc_front_chain_lang.php');
// reset all 2nd level lock cookies
require($root_path.'include/inc_2level_reset.php');

global $db;
$thisfile=basename(__FILE__);
$breakfile=$root_path.'interconsulta/interconsulta.php'.URL_APPEND;
$action="interconsulta-usutriaje-save.php";
$_SESSION['sess_path_referer']=$top_dir.$thisfile;

# Start Smarty templating here
/**
* LOAD Smarty
*/

# Note: it is advisable to load this after the inc_front_chain_lang.php so
# that the smarty script can use the user configured template theme

?>
                <script  language="javascript">

                function popSearchWin(target,obj_val,obj_name){
                        urlholder="./data_search.php<?php echo URL_REDIRECT_APPEND; ?>&target="+target+"&obj_val="+obj_val+"&obj_name="+obj_name;
                        DSWIN<?php echo $sid ?>=window.open(urlholder,"wblabel<?php echo $sid ?>","menubar=no,width=400,height=550,resizable=yes,scrollbars=yes");
                }

                function grupoBlur()
                {
                    <?php
                        //$sql = "SELECT login_id, name from care_users WHERE permission='_a_2_intertriajewrite'";
						$sql = $query_interconsulta_usutriaje->select_care_users();

                        $i = 0;
                        if($result=$db->Execute($sql)){
                            while($temp=$result->FetchRow())
                            {
                                echo 'var option0 = new Option("' . $temp['name'] . '", "' . $temp['login_id'] . '");';
                                echo 'document.regform.noasig.options[' . $i . '] = option0;';
                                $i++;
                            }
                        }
                    ?>
                }

                function getAsig()
                {
                    var sda1 = document.getElementById('asig');
                    var len = sda1.length;
                    var acum = "";

                    for (var j=0;j<len;j++)
                    {
                        acum += sda1.options[j].value + ":";
                    }

                    document.getElementById('asigacum').value = acum;

                    return true;
                }

                function moveoutid()
                {
                        var sda = document.getElementById('noasig');;
                        var len = sda.length;
                        var sda1 = document.getElementById('asig');
                        for(var j=0; j<len; j++)
                        {
                                if(sda[j].selected)
                                {
                                        var tmp = sda.options[j].text;
                                        var tmp1 = sda.options[j].value;
                                        sda.remove(j);
                                        j--;
                                        var y=document.createElement('option');
                                        y.text=tmp;
                                        y.value=tmp1;
                                        try
                                        {sda1.add(y,null);
                                        }
                                        catch(ex)
                                        {
                                        sda1.add(y);
                                        }
                                }
                        }
                }


                function moveinid()
                {
                        var sda = document.getElementById('noasig');
                        var sda1 = document.getElementById('asig');
                        var len = sda1.length;
                        for(var j=0; j<len; j++)
                        {
                                if(sda1[j].selected)
                                {
                                        var tmp = sda1.options[j].text;
                                        var tmp1 = sda1.options[j].value;
                                        sda1.remove(j);
                                        j--;
                                        var y=document.createElement('option');
                                        y.text=tmp;
                                        y.value=tmp1;
                                        try
                                        {
                                        sda.add(y,null);}
                                        catch(ex){
                                        sda.add(y);	
                                        }
                                }
                        }
                }

        </script>
<?php

require_once($root_path.'gui/smarty_template/smarty_care.class.php');
$smarty = new smarty_care('common');

# Create a helper smarty object without reinitializing the GUI
$smarty2 = new smarty_care('common', FALSE);

# Added for the common header top block

$smarty->assign('sToolbarTitle',$LDInter);
$smarty->assign('breakfile',$breakfile);
$smarty->assign('action',$action);

# Window bar title
$smarty->assign('title',$LDUsuTriaje);

$smarty->assign('LDGrupo',$LDGroup);
$smarty->assign('sGrupoInput','<input name="nombre" type="text" size="10" onblur="grupoBlur()">');
$smarty->assign('sGrupoMiniCalendar',"<a href=\"javascript:popSearchWin('grupo')\"><img ".createComIcon($root_path,'b-write_addr.gif','0')."></a>");

$smarty->assign('LDUsuarios',$LDUsers);
$smarty->assign('sNoAsigSelect','<select name="noasig[]" id="noasig" multiple size="7" width="10"></select>');
$smarty->assign('sAsigSelect','<select name="asig[]" id="asig" multiple size="7" width="10"></select>');
$smarty->assign('pbAddRem', '<input type="button" value=">>" onclick="moveoutid()"><br><input type="button" value="<<" onclick="moveinid()">');

$smarty->assign('asigacum', '<input type="hidden" value="" name="asigacum" id="asigacum">');

$smarty->assign('pbSubmit','<input type="image" '.createLDImgSrc($root_path,'savedisc.gif','0').'  alt="'.$LDSaveData.'" align="absmiddle">');

$smarty->assign('sMainBlockIncludeFile','interconsulta/usutriaje.tpl');

/**
* show Template
*/

$smarty->display('common/mainframe.tpl');
?>
